fix: restore reserved suffix stripping in PrometheusNaming.sanitizeMetricName()#2124
Merged
zeitlinger merged 1 commit intoMay 20, 2026
Conversation
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
This was referenced May 18, 2026
jaydeluca
approved these changes
May 19, 2026
zeitlinger
added a commit
that referenced
this pull request
May 22, 2026
Draft validation PR for the unmodified Micrometer compatibility story. This intentionally does **not** depend on #2114. Vanilla Micrometer does not use the typed descriptor API and does not implement the #1800 registration metadata hooks, so this PR validates the patch-compatible path independently of typed descriptors. This validates upstream `micrometer-metrics/micrometer@main` against: - current `main`, which already includes #2100 and #2124 (reserved suffix stripping in `PrometheusNaming.sanitizeMetricName()`). - Micrometer compatibility test tooling/workflow from zeitlinger#1. Local validation: - `mise run lint` - `MICROMETER_DIR=/tmp/micrometer-compat-vanilla-2124 mise run micrometer:test` --------- Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com> Co-authored-by: Jay DeLuca <jaydeluca4@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2087.
Supersedes #2094 with the same fix on a clean, signed-off commit so the DCO
check can pass.
sanitizeMetricName()was simplified in 1.6.0 to return its input unchangedbecause any non-empty UTF-8 string is now a valid metric name. That silently
broke downstream tools — notably the JMX Exporter and the simpleclient bridge —
that call
sanitizeMetricName()to normalize external names before passing themto snapshot builders.
The missing stripping means a JMX attribute that produces
kafka_consumer_request_totalas a raw name is no longer sanitized tokafka_consumer_request. WithinferCounterTypeFromName: truethis triggersunintended counter-type inference; with it
falsethe metric is stored under thewrong name, breaking exact-name registry lookups.
Changes
RESERVED_METRIC_NAME_SUFFIXESand the iterative suffix-stripping loopin
PrometheusNaming.sanitizeMetricName()."_total"->"total", in a dedicatedpre-pass before the stripping loop.
PrometheusNamingTestandMetricMetadataTestexpectations.case, for example
.total.Counter.builder().name("events_total")is unaffected because the builder APIdoes not go through
sanitizeMetricName().Validation
mise run build